package com.xyazm.order.statemachine.action.order.create.node;

import com.xyazm.order.domain.param.CreateOrderParam;
import com.xyazm.order.mapstruct.OrderApiMapstruct;
import com.xyazm.order.remote.RiskRemote;
import com.xyazm.process.engine.process.ProcessContext;
import com.xyazm.process.engine.process.StandardProcessor;
import com.xyazm.risk.domain.param.CheckOrderRiskParam;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 创建订单 风控检查节点
 * @author xuyou
 * @date 2023年02月01日 22:03
 */
@Component
public class CreateOrderRiskCheckNode extends StandardProcessor {

    @Resource
    private RiskRemote riskRemote;

    @Override
    protected void processInternal(ProcessContext context) {
        CreateOrderParam param = context.get("createOrderParam");
        CheckOrderRiskParam checkOrderRiskParam = OrderApiMapstruct.INSTANCE.convertCheckOrderRiskParam(param);
        riskRemote.checkOrderRisk(checkOrderRiskParam);
    }
}
